Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-104527: Add check to not recursively write zipfile #104857

Closed
wants to merge 6 commits into from

Conversation

PurityLake
Copy link
Contributor

@PurityLake PurityLake commented May 24, 2023

Refers to #104527

When writing to a zipfile, I have added a check for ensuring that there is no recursive writing of the open zipfile into that zipfile. I use os.path.abspath to ensure the file names are exactly the same.

@@ -1817,6 +1817,11 @@ def write(self, filename, arcname=None,
zinfo = ZipInfo.from_file(filename, arcname,
strict_timestamps=self._strict_timestamps)

if isinstance(self.filename, os.PathLike) or isinstance(self.filename, bytes) \
or isinstance(self.filename, str):
if os.path.abspath(filename) == os.path.abspath(self.filename):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might want to use os.path.resolve() here, to resolve symlinks as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will make this fix later on today

@PurityLake PurityLake closed this Mar 14, 2024
@PurityLake PurityLake deleted the gh104527-fix branch March 14, 2024 02:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants